#include<iostream>
#include<vector>
#include<unordered_map>

using namespace std;

class Solution {
public:
	//bool isIsomorphic(string s, string t) {
	//	unordered_map<char, char> s2t;
	//	unordered_map<char, char> t2s;
	//	int len = s.length();
	//	for (int i = 0; i < len; ++i) {
	//		char x = s[i], y = t[i];
	//		if ((s2t.count(x) && s2t[x] != y) || (t2s.count(y) && t2s[y] != x)) {
	//			return false;
	//		}
	//		s2t[x] = y;
	//		t2s[y] = x;
	//	}
	//	return true;
	//}

	bool isIsomorphic(string s, string t) {
		unordered_map<char, char> s2t;
		unordered_map<char, char> t2s;
		for (int i = 0; i < s.length(); i++) {
			auto shash = s2t.find(s[i]);
			auto thash = t2s.find(t[i]);
			if ((shash != s2t.end() && thash == t2s.end()) || shash == s2t.end() && thash != t2s.end())
				return false;
			if (shash != s2t.end() && thash != t2s.end()) {
				if (shash->second != thash->first)
					return false;
			}
			s2t[s[i]] = t[i];
			t2s[t[i]] = s[i];
		}
		return true;
	}

};

int main() {
	string s = "badc", t = "baba";
	Solution so;
	if (so.isIsomorphic(s, t)) {
		cout << "yes" << endl;
	}
	else cout << "no" << endl;
	return 0;
}